<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="订单号" prop="orderId">
        <el-input
          v-model="queryParams.orderId"
          placeholder="请输入订单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单类型" prop="type">
        <el-input
          v-model="queryParams.type"
          placeholder="请输入订单类型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="用户姓名" prop="realName">-->
<!--        <el-input-->
<!--          v-model="queryParams.realName"-->
<!--          placeholder="请输入用户姓名"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="支付状态" prop="paid">
        <el-input
          v-model="queryParams.paid"
          placeholder="请输入支付状态"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:storeOrder:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:storeOrder:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:storeOrder:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:storeOrder:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="storeOrderList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="订单ID" align="center" prop="id" v-if="true"/>
      <el-table-column label="订单号" align="center" prop="orderId" />
      <el-table-column label="用户姓名" align="center" prop="realName" />
<!--      <el-table-column label="用户电话" align="center" prop="userPhone" />-->
<!--      <el-table-column label="详细地址" align="center" prop="userAddress" />-->
<!--      <el-table-column label="运费金额" align="center" prop="freightPrice" />-->
<!--      <el-table-column label="订单商品总数" align="center" prop="totalNum" />-->
<!--      <el-table-column label="订单总价" align="center" prop="totalPrice" />-->
<!--      <el-table-column label="邮费" align="center" prop="totalPostage" />-->
      <el-table-column label="实际支付金额" align="center" prop="payPrice" />
<!--      <el-table-column label="支付邮费" align="center" prop="payPostage" />-->
<!--      <el-table-column label="抵扣金额" align="center" prop="deductionPrice" />-->
<!--      <el-table-column label="优惠券id" align="center" prop="couponId" />-->
<!--      <el-table-column label="优惠券金额" align="center" prop="couponPrice" />-->
<!--      <el-table-column label="支付状态" align="center" prop="paid" />-->
      <el-table-column label="下单时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="支付方式" align="center" prop="payType" />
      <el-table-column label="订单状态" align="center" prop="status" />
<!--      <el-table-column label="0 未退款 1 申请中 2 已退款 3 退款中" align="center" prop="refundStatus" />-->
<!--      <el-table-column label="退款图片" align="center" prop="refundReasonWapImg" />-->
<!--      <el-table-column label="退款用户说明" align="center" prop="refundReasonWapExplain" />-->
<!--      <el-table-column label="前台退款原因" align="center" prop="refundReasonWap" />-->
<!--      <el-table-column label="不退款的理由" align="center" prop="refundReason" />-->
<!--      <el-table-column label="退款时间" align="center" prop="refundReasonTime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.refundReasonTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="退款金额" align="center" prop="refundPrice" />-->
<!--      <el-table-column label="快递名称/送货人姓名" align="center" prop="deliveryName" />-->
<!--      <el-table-column label="发货类型" align="center" prop="deliveryType" />-->
<!--      <el-table-column label="快递单号/手机号" align="center" prop="deliveryId" />-->
<!--      <el-table-column label="消费赚取积分" align="center" prop="gainIntegral" />-->
<!--      <el-table-column label="使用积分" align="center" prop="useIntegral" />-->
<!--      <el-table-column label="给用户退了多少积分" align="center" prop="backIntegral" />-->
<!--      <el-table-column label="备注" align="center" prop="mark" />-->
<!--      <el-table-column label="管理员备注" align="center" prop="remark" />-->
<!--      <el-table-column label="商户ID" align="center" prop="merId" />-->
<!--      <el-table-column label="" align="center" prop="isMerCheck" />-->
<!--      <el-table-column label="拼团商品id0一般商品" align="center" prop="combinationId" />-->
<!--      <el-table-column label="拼团id 0没有拼团" align="center" prop="pinkId" />-->
<!--      <el-table-column label="成本价" align="center" prop="cost" />-->
<!--      <el-table-column label="秒杀商品ID" align="center" prop="seckillId" />-->
<!--      <el-table-column label="砍价id" align="center" prop="bargainId" />-->
<!--      <el-table-column label="核销码" align="center" prop="verifyCode" />-->
<!--      <el-table-column label="门店id" align="center" prop="storeId" />-->
<!--      <el-table-column label="配送方式 1=快递 ，2=门店自提" align="center" prop="shippingType" />-->
<!--      <el-table-column label="店员id/核销员id" align="center" prop="clerkId" />-->
<!--      <el-table-column label="支付渠道(0微信公众号1微信小程序2余额)" align="center" prop="isChannel" />-->
<!--      <el-table-column label="消息提醒" align="center" prop="isRemind" />-->
<!--      <el-table-column label="后台是否删除" align="center" prop="isSystemDel" />-->
<!--      <el-table-column label="快递公司简称" align="center" prop="deliveryCode" />-->
<!--      <el-table-column label="用户拼团活动id 0没有" align="center" prop="bargainUserId" />-->
<!--      <el-table-column label="订单类型:0-普通订单，1-视频号订单" align="center" prop="type" />-->
<!--      <el-table-column label="商品总价" align="center" prop="proTotalPrice" />-->
<!--      <el-table-column label="改价前支付金额" align="center" prop="beforePayPrice" />-->
<!--      <el-table-column label="是否改价,0-否，1-是" align="center" prop="isAlterPrice" />-->
<!--      <el-table-column label="商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号" align="center" prop="outTradeNo" />-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:storeOrder:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:storeOrder:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改订单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="订单号" prop="orderId">
          <el-input v-model="form.orderId" placeholder="请输入订单号" />
        </el-form-item>
        <el-form-item label="用户id" prop="uid">
          <el-input v-model="form.uid" placeholder="请输入用户id" />
        </el-form-item>
        <el-form-item label="用户姓名" prop="realName">
          <el-input v-model="form.realName" placeholder="请输入用户姓名" />
        </el-form-item>
        <el-form-item label="用户电话" prop="userPhone">
          <el-input v-model="form.userPhone" placeholder="请输入用户电话" />
        </el-form-item>
        <el-form-item label="详细地址" prop="userAddress">
          <el-input v-model="form.userAddress" placeholder="请输入详细地址" />
        </el-form-item>
        <el-form-item label="运费金额" prop="freightPrice">
          <el-input v-model="form.freightPrice" placeholder="请输入运费金额" />
        </el-form-item>
        <el-form-item label="订单商品总数" prop="totalNum">
          <el-input v-model="form.totalNum" placeholder="请输入订单商品总数" />
        </el-form-item>
        <el-form-item label="订单总价" prop="totalPrice">
          <el-input v-model="form.totalPrice" placeholder="请输入订单总价" />
        </el-form-item>
        <el-form-item label="邮费" prop="totalPostage">
          <el-input v-model="form.totalPostage" placeholder="请输入邮费" />
        </el-form-item>
        <el-form-item label="实际支付金额" prop="payPrice">
          <el-input v-model="form.payPrice" placeholder="请输入实际支付金额" />
        </el-form-item>
        <el-form-item label="支付邮费" prop="payPostage">
          <el-input v-model="form.payPostage" placeholder="请输入支付邮费" />
        </el-form-item>
        <el-form-item label="抵扣金额" prop="deductionPrice">
          <el-input v-model="form.deductionPrice" placeholder="请输入抵扣金额" />
        </el-form-item>
        <el-form-item label="优惠券id" prop="couponId">
          <el-input v-model="form.couponId" placeholder="请输入优惠券id" />
        </el-form-item>
        <el-form-item label="优惠券金额" prop="couponPrice">
          <el-input v-model="form.couponPrice" placeholder="请输入优惠券金额" />
        </el-form-item>
        <el-form-item label="支付状态" prop="paid">
          <el-input v-model="form.paid" placeholder="请输入支付状态" />
        </el-form-item>
        <el-form-item label="支付时间" prop="payTime">
          <el-date-picker clearable
            v-model="form.payTime"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择支付时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="退款图片" prop="refundReasonWapImg">
          <el-input v-model="form.refundReasonWapImg" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="退款用户说明" prop="refundReasonWapExplain">
          <el-input v-model="form.refundReasonWapExplain" placeholder="请输入退款用户说明" />
        </el-form-item>
        <el-form-item label="前台退款原因" prop="refundReasonWap">
          <el-input v-model="form.refundReasonWap" placeholder="请输入前台退款原因" />
        </el-form-item>
        <el-form-item label="不退款的理由" prop="refundReason">
          <el-input v-model="form.refundReason" placeholder="请输入不退款的理由" />
        </el-form-item>
        <el-form-item label="退款时间" prop="refundReasonTime">
          <el-date-picker clearable
            v-model="form.refundReasonTime"
            type="datetime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择退款时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="退款金额" prop="refundPrice">
          <el-input v-model="form.refundPrice" placeholder="请输入退款金额" />
        </el-form-item>
        <el-form-item label="快递名称/送货人姓名" prop="deliveryName">
          <el-input v-model="form.deliveryName" placeholder="请输入快递名称/送货人姓名" />
        </el-form-item>
        <el-form-item label="快递单号/手机号" prop="deliveryId">
          <el-input v-model="form.deliveryId" placeholder="请输入快递单号/手机号" />
        </el-form-item>
        <el-form-item label="消费赚取积分" prop="gainIntegral">
          <el-input v-model="form.gainIntegral" placeholder="请输入消费赚取积分" />
        </el-form-item>
        <el-form-item label="使用积分" prop="useIntegral">
          <el-input v-model="form.useIntegral" placeholder="请输入使用积分" />
        </el-form-item>
        <el-form-item label="给用户退了多少积分" prop="backIntegral">
          <el-input v-model="form.backIntegral" placeholder="请输入给用户退了多少积分" />
        </el-form-item>
        <el-form-item label="备注" prop="mark">
          <el-input v-model="form.mark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="管理员备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="商户ID" prop="merId">
          <el-input v-model="form.merId" placeholder="请输入商户ID" />
        </el-form-item>
        <el-form-item label="" prop="isMerCheck">
          <el-input v-model="form.isMerCheck" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="拼团商品id0一般商品" prop="combinationId">
          <el-input v-model="form.combinationId" placeholder="请输入拼团商品id0一般商品" />
        </el-form-item>
        <el-form-item label="拼团id 0没有拼团" prop="pinkId">
          <el-input v-model="form.pinkId" placeholder="请输入拼团id 0没有拼团" />
        </el-form-item>
        <el-form-item label="成本价" prop="cost">
          <el-input v-model="form.cost" placeholder="请输入成本价" />
        </el-form-item>
        <el-form-item label="秒杀商品ID" prop="seckillId">
          <el-input v-model="form.seckillId" placeholder="请输入秒杀商品ID" />
        </el-form-item>
        <el-form-item label="砍价id" prop="bargainId">
          <el-input v-model="form.bargainId" placeholder="请输入砍价id" />
        </el-form-item>
        <el-form-item label="核销码" prop="verifyCode">
          <el-input v-model="form.verifyCode" placeholder="请输入核销码" />
        </el-form-item>
        <el-form-item label="门店id" prop="storeId">
          <el-input v-model="form.storeId" placeholder="请输入门店id" />
        </el-form-item>
        <el-form-item label="店员id/核销员id" prop="clerkId">
          <el-input v-model="form.clerkId" placeholder="请输入店员id/核销员id" />
        </el-form-item>
        <el-form-item label="支付渠道(0微信公众号1微信小程序2余额)" prop="isChannel">
          <el-input v-model="form.isChannel" placeholder="请输入支付渠道(0微信公众号1微信小程序2余额)" />
        </el-form-item>
        <el-form-item label="消息提醒" prop="isRemind">
          <el-input v-model="form.isRemind" placeholder="请输入消息提醒" />
        </el-form-item>
        <el-form-item label="后台是否删除" prop="isSystemDel">
          <el-input v-model="form.isSystemDel" placeholder="请输入后台是否删除" />
        </el-form-item>
        <el-form-item label="快递公司简称" prop="deliveryCode">
          <el-input v-model="form.deliveryCode" placeholder="请输入快递公司简称" />
        </el-form-item>
        <el-form-item label="用户拼团活动id 0没有" prop="bargainUserId">
          <el-input v-model="form.bargainUserId" placeholder="请输入用户拼团活动id 0没有" />
        </el-form-item>
        <el-form-item label="商品总价" prop="proTotalPrice">
          <el-input v-model="form.proTotalPrice" placeholder="请输入商品总价" />
        </el-form-item>
        <el-form-item label="改价前支付金额" prop="beforePayPrice">
          <el-input v-model="form.beforePayPrice" placeholder="请输入改价前支付金额" />
        </el-form-item>
        <el-form-item label="是否改价,0-否，1-是" prop="isAlterPrice">
          <el-input v-model="form.isAlterPrice" placeholder="请输入是否改价,0-否，1-是" />
        </el-form-item>
        <el-form-item label="商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号" prop="outTradeNo">
          <el-input v-model="form.outTradeNo" placeholder="请输入商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listStoreOrder, getStoreOrder, delStoreOrder, addStoreOrder, updateStoreOrder } from "@/api/system/storeOrder";

export default {
  name: "StoreOrder",
  data() {
    return {
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 订单表格数据
      storeOrderList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderId: undefined,
        uid: undefined,
        realName: undefined,
        userPhone: undefined,
        userAddress: undefined,
        freightPrice: undefined,
        totalNum: undefined,
        totalPrice: undefined,
        totalPostage: undefined,
        payPrice: undefined,
        payPostage: undefined,
        deductionPrice: undefined,
        couponId: undefined,
        couponPrice: undefined,
        paid: undefined,
        payTime: undefined,
        payType: undefined,
        status: undefined,
        refundStatus: undefined,
        refundReasonWapImg: undefined,
        refundReasonWapExplain: undefined,
        refundReasonWap: undefined,
        refundReason: undefined,
        refundReasonTime: undefined,
        refundPrice: undefined,
        deliveryName: undefined,
        deliveryType: undefined,
        deliveryId: undefined,
        gainIntegral: undefined,
        useIntegral: undefined,
        backIntegral: undefined,
        mark: undefined,
        merId: undefined,
        isMerCheck: undefined,
        combinationId: undefined,
        pinkId: undefined,
        cost: undefined,
        seckillId: undefined,
        bargainId: undefined,
        verifyCode: undefined,
        storeId: undefined,
        shippingType: undefined,
        clerkId: undefined,
        isChannel: undefined,
        isRemind: undefined,
        isSystemDel: undefined,
        deliveryCode: undefined,
        bargainUserId: undefined,
        type: undefined,
        proTotalPrice: undefined,
        beforePayPrice: undefined,
        isAlterPrice: undefined,
        outTradeNo: undefined
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        id: [
          { required: true, message: "订单ID不能为空", trigger: "blur" }
        ],
        orderId: [
          { required: true, message: "订单号不能为空", trigger: "blur" }
        ],
        uid: [
          { required: true, message: "用户id不能为空", trigger: "blur" }
        ],
        realName: [
          { required: true, message: "用户姓名不能为空", trigger: "blur" }
        ],
        userPhone: [
          { required: true, message: "用户电话不能为空", trigger: "blur" }
        ],
        userAddress: [
          { required: true, message: "详细地址不能为空", trigger: "blur" }
        ],
        freightPrice: [
          { required: true, message: "运费金额不能为空", trigger: "blur" }
        ],
        totalNum: [
          { required: true, message: "订单商品总数不能为空", trigger: "blur" }
        ],
        totalPrice: [
          { required: true, message: "订单总价不能为空", trigger: "blur" }
        ],
        totalPostage: [
          { required: true, message: "邮费不能为空", trigger: "blur" }
        ],
        payPrice: [
          { required: true, message: "实际支付金额不能为空", trigger: "blur" }
        ],
        payPostage: [
          { required: true, message: "支付邮费不能为空", trigger: "blur" }
        ],
        deductionPrice: [
          { required: true, message: "抵扣金额不能为空", trigger: "blur" }
        ],
        couponId: [
          { required: true, message: "优惠券id不能为空", trigger: "blur" }
        ],
        couponPrice: [
          { required: true, message: "优惠券金额不能为空", trigger: "blur" }
        ],
        paid: [
          { required: true, message: "支付状态不能为空", trigger: "blur" }
        ],
        payTime: [
          { required: true, message: "支付时间不能为空", trigger: "blur" }
        ],
        payType: [
          { required: true, message: "支付方式不能为空", trigger: "change" }
        ],
        status: [
          { required: true, message: "订单状态不能为空", trigger: "blur" }
        ],
        refundStatus: [
          { required: true, message: "0 未退款 1 申请中 2 已退款 3 退款中不能为空", trigger: "blur" }
        ],
        refundReasonWapImg: [
          { required: true, message: "退款图片不能为空", trigger: "blur" }
        ],
        refundReasonWapExplain: [
          { required: true, message: "退款用户说明不能为空", trigger: "blur" }
        ],
        refundReasonWap: [
          { required: true, message: "前台退款原因不能为空", trigger: "blur" }
        ],
        refundReason: [
          { required: true, message: "不退款的理由不能为空", trigger: "blur" }
        ],
        refundReasonTime: [
          { required: true, message: "退款时间不能为空", trigger: "blur" }
        ],
        refundPrice: [
          { required: true, message: "退款金额不能为空", trigger: "blur" }
        ],
        deliveryName: [
          { required: true, message: "快递名称/送货人姓名不能为空", trigger: "blur" }
        ],
        deliveryType: [
          { required: true, message: "发货类型不能为空", trigger: "change" }
        ],
        deliveryId: [
          { required: true, message: "快递单号/手机号不能为空", trigger: "blur" }
        ],
        gainIntegral: [
          { required: true, message: "消费赚取积分不能为空", trigger: "blur" }
        ],
        useIntegral: [
          { required: true, message: "使用积分不能为空", trigger: "blur" }
        ],
        backIntegral: [
          { required: true, message: "给用户退了多少积分不能为空", trigger: "blur" }
        ],
        mark: [
          { required: true, message: "备注不能为空", trigger: "blur" }
        ],
        remark: [
          { required: true, message: "管理员备注不能为空", trigger: "blur" }
        ],
        merId: [
          { required: true, message: "商户ID不能为空", trigger: "blur" }
        ],
        isMerCheck: [
          { required: true, message: "不能为空", trigger: "blur" }
        ],
        combinationId: [
          { required: true, message: "拼团商品id0一般商品不能为空", trigger: "blur" }
        ],
        pinkId: [
          { required: true, message: "拼团id 0没有拼团不能为空", trigger: "blur" }
        ],
        cost: [
          { required: true, message: "成本价不能为空", trigger: "blur" }
        ],
        seckillId: [
          { required: true, message: "秒杀商品ID不能为空", trigger: "blur" }
        ],
        bargainId: [
          { required: true, message: "砍价id不能为空", trigger: "blur" }
        ],
        verifyCode: [
          { required: true, message: "核销码不能为空", trigger: "blur" }
        ],
        storeId: [
          { required: true, message: "门店id不能为空", trigger: "blur" }
        ],
        shippingType: [
          { required: true, message: "配送方式 1=快递 ，2=门店自提不能为空", trigger: "change" }
        ],
        clerkId: [
          { required: true, message: "店员id/核销员id不能为空", trigger: "blur" }
        ],
        isChannel: [
          { required: true, message: "支付渠道(0微信公众号1微信小程序2余额)不能为空", trigger: "blur" }
        ],
        isRemind: [
          { required: true, message: "消息提醒不能为空", trigger: "blur" }
        ],
        isSystemDel: [
          { required: true, message: "后台是否删除不能为空", trigger: "blur" }
        ],
        updateTime: [
          { required: true, message: "更新时间不能为空", trigger: "blur" }
        ],
        deliveryCode: [
          { required: true, message: "快递公司简称不能为空", trigger: "blur" }
        ],
        bargainUserId: [
          { required: true, message: "用户拼团活动id 0没有不能为空", trigger: "blur" }
        ],
        type: [
          { required: true, message: "订单类型:0-普通订单，1-视频号订单不能为空", trigger: "change" }
        ],
        proTotalPrice: [
          { required: true, message: "商品总价不能为空", trigger: "blur" }
        ],
        beforePayPrice: [
          { required: true, message: "改价前支付金额不能为空", trigger: "blur" }
        ],
        isAlterPrice: [
          { required: true, message: "是否改价,0-否，1-是不能为空", trigger: "blur" }
        ],
        outTradeNo: [
          { required: true, message: "商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号不能为空", trigger: "blur" }
        ]
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询订单列表 */
    getList() {
      this.loading = true;
      listStoreOrder(this.queryParams).then(response => {
        this.storeOrderList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        orderId: undefined,
        uid: undefined,
        realName: undefined,
        userPhone: undefined,
        userAddress: undefined,
        freightPrice: undefined,
        totalNum: undefined,
        totalPrice: undefined,
        totalPostage: undefined,
        payPrice: undefined,
        payPostage: undefined,
        deductionPrice: undefined,
        couponId: undefined,
        couponPrice: undefined,
        paid: undefined,
        payTime: undefined,
        payType: undefined,
        createTime: undefined,
        status: 0,
        refundStatus: 0,
        refundReasonWapImg: undefined,
        refundReasonWapExplain: undefined,
        refundReasonWap: undefined,
        refundReason: undefined,
        refundReasonTime: undefined,
        refundPrice: undefined,
        deliveryName: undefined,
        deliveryType: undefined,
        deliveryId: undefined,
        gainIntegral: undefined,
        useIntegral: undefined,
        backIntegral: undefined,
        mark: undefined,
        remark: undefined,
        merId: undefined,
        isMerCheck: undefined,
        combinationId: undefined,
        pinkId: undefined,
        cost: undefined,
        seckillId: undefined,
        bargainId: undefined,
        verifyCode: undefined,
        storeId: undefined,
        shippingType: undefined,
        clerkId: undefined,
        isChannel: undefined,
        isRemind: undefined,
        isSystemDel: undefined,
        updateTime: undefined,
        deliveryCode: undefined,
        bargainUserId: undefined,
        type: undefined,
        proTotalPrice: undefined,
        beforePayPrice: undefined,
        isAlterPrice: undefined,
        outTradeNo: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加订单";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.loading = true;
      this.reset();
      const id = row.id || this.ids
      getStoreOrder(id).then(response => {
        this.loading = false;
        this.form = response.data;
        this.open = true;
        this.title = "修改订单";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.buttonLoading = true;
          if (this.form.id != null) {
            updateStoreOrder(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            }).finally(() => {
              this.buttonLoading = false;
            });
          } else {
            addStoreOrder(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            }).finally(() => {
              this.buttonLoading = false;
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除订单编号为"' + ids + '"的数据项？').then(() => {
        this.loading = true;
        return delStoreOrder(ids);
      }).then(() => {
        this.loading = false;
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).finally(() => {
        this.loading = false;
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/storeOrder/export', {
        ...this.queryParams
      }, `storeOrder_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
